﻿using System;
using System.Data;
using System.Windows.Forms;

namespace idataplatform
{
    public partial class basedetail1 : Form
    {
        private string infoind;
        public basedetail1(string strvalue)
        {
            InitializeComponent();
            infoind = strvalue;
        }

        private void basedetail1_Load(object sender, EventArgs e)
        {
            if (infoind != null)
            {
                DataTable dt = new DataTable();
                string SQLsel = "SELECT ind,iname,brand,type,area,floor FROM baseinfo_ipark where ind=" + infoind;

                conncls conn = new conncls();
                dt = conn.Dts(SQLsel);
                if (dt.Rows.Count > 0)
                {
                    textBox1.Text = dt.Rows[0][0].ToString();
                    textBox3.Text = dt.Rows[0][4].ToString();
                    textBox4.Text = dt.Rows[0][3].ToString();
                    textBox5.Text = dt.Rows[0][2].ToString();
                    textBox6.Text = dt.Rows[0][1].ToString();
                    comboBox1.Text = dt.Rows[0][5].ToString();
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "修 改")
            {
                button1.Text = "保 存";
                textBox3.Enabled = true;
                textBox4.Enabled = true;
                textBox5.Enabled = true;
                textBox6.Enabled = true;
                comboBox1.Enabled = true;

                button2.Visible = true;
            }
            else
            {
                button1.Text = "修 改";
                textBox3.Enabled = false;
                textBox4.Enabled = false;
                textBox5.Enabled = false;
                textBox6.Enabled = false;
                comboBox1.Enabled = false;

                button2.Visible = false;

                string UPsql = "UPDATE baseinfo_ipark SET iname=\"" + textBox6.Text + "\",brand=\"" + textBox5.Text + "\",type=\"" + textBox4.Text + "\",area=" + textBox3.Text + ",floor=\"" + comboBox1.Text + "\" WHERE ind=" + textBox1.Text;
                conncls conns = new conncls();
                conns.sqlexec(UPsql);

                pubcls.freshmark1 = true;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            button1.Text = "修 改";
            textBox3.Enabled = false;
            textBox4.Enabled = false;
            textBox5.Enabled = false;
            textBox6.Enabled = false;
            comboBox1.Enabled = false;

            button2.Visible = false;
        }
    }
}
